/*    */ package com.zimbra.cs.mailbox;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.mime.Mime;
/*    */ import java.io.IOException;
/*    */ import java.io.InputStream;
/*    */ import java.io.OutputStream;
/*    */ import javax.activation.DataSource;
/*    */ import javax.mail.MessagingException;
/*    */ import javax.mail.internet.MimeMessage;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class MessageDataSource
/*    */   implements DataSource
/*    */ {
/*    */   private Message mMessage;
/*    */   private String mContentType;
/*    */   
/*    */   public MessageDataSource(Message message)
/*    */     throws MessagingException, ServiceException
/*    */   {
/* 37 */     if (message == null) {
/* 38 */       throw new NullPointerException("message cannot be null");
/*    */     }
/* 40 */     this.mMessage = message;
/* 41 */     this.mContentType = message.getMimeMessage().getContentType();
/*    */   }
/*    */   
/*    */   public String getContentType() {
/* 45 */     return this.mContentType;
/*    */   }
/*    */   
/*    */   public InputStream getInputStream() throws IOException {
/*    */     try {
/* 50 */       return Mime.getInputStream(this.mMessage.getMimeMessage());
/*    */     } catch (Exception e) {
/* 52 */       ZimbraLog.mailbox.error("Unable to get stream to message " + this.mMessage.getId(), e);
/* 53 */       throw new IOException(e.toString());
/*    */     }
/*    */   }
/*    */   
/*    */   public String getName() {
/* 58 */     return this.mMessage.getSubject();
/*    */   }
/*    */   
/*    */   public OutputStream getOutputStream() {
/* 62 */     throw new UnsupportedOperationException();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailbox/MessageDataSource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */